<template>
  <div>
    <el-form :label-position="labelPosition" label-width="80px">
      <el-form-item label="账号">
        <el-input v-model="acc"></el-input>
      </el-form-item>
      <el-form-item label="密码" prop="pass">
        <el-input type="password" v-model="pass" autocomplete="off"></el-input>
      </el-form-item>

      <el-form-item label="用户组" prop="region">
        <el-select v-model="region" placeholder="请选择管理员">
          <el-option label="超级管理员" value="超级管理员"></el-option>
          <el-option label="普通管理员" value="普通管理员"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="funAdd">添加</el-button>
        <el-button @click="funReset">重置</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
import { accadd } from "../../apis/user";

export default {
  data() {
    return {
      labelPosition: "right",
      acc: "",
      region: "普通管理员",
      type: "",
      pass: "",
    };
  },
  methods: {
    funAdd() {
      accadd({
        account: this.acc,
        password: this.pass,
        userGroup: this.region,
      }).then((res) => {
        if (res.data.code == 0) {
          this.$message({
            message: "外卖商家：超级管理员添加成功",
            type: "success",
          });
        }
        this.funReset()
      });
    },
    //重置
    funReset(){
      this.acc='';
      this.pass='';
      this.region='普通管理员'
    }
  },
};
</script>

<style lang="less">
.el-main[data-v-fae5bece] {
  background-color: #e9eef3;
  color: #333;
  text-align: left;
  line-height: 50px;
}

.el-input__inner {
  width: 210px;
}
</style>